//
//  DLNormalWebVC.m
//  delongzhitou
//
//  Created by Mr.Wang on 2019/1/11.
//  Copyright © 2019 delongzhitou. All rights reserved.
//

#import "DLNormalWebVC.h"

@interface DLNormalWebVC ()

@end

@implementation DLNormalWebVC

- (void) webViewDidFinishLoad:(UIWebView *)webView{
    
    NSLog(@"webViewDidFinishLoad");
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    switch (self.webViewType) {
        case DLWebViewType_wholeUrl:
        {
            [self.baseWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
        }
            break;
        case DLWebViewType_InfoDetail:
        {
            //platform
            NSString *platform = @"ios";
            
            //token
            NSString *token = kuserManager.isLogin?kuserManager.userInfoModel.token:@"";
            
            //devicecode
            NSString *uniqueId = [DLKeyChainManager readUUID];
            if (isEmpty(uniqueId)) {
                uniqueId = [DLKeyChainManager createUUID];
                [DLKeyChainManager saveUUID:uniqueId];
            }
            
            //version
            NSString *version = ([[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]);
            
            //userid
            NSString *userId = kuserManager.isLogin?kuserManager.userInfoModel.userid:@"";
            
            //newsid
            NSString *newsId = self.newsId;
            
            NSString *webUrl = [NSString stringWithFormat:@"%@platform=%@&token=%@&devicecode=%@&version=%@&user_id=%@&id=%@", self.urlString, platform, token, uniqueId, version, userId, newsId];
            [self.baseWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:webUrl]]];
        }
            break;
        default:
            break;
    }
    
    // Do any additional setup after loading the view.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
